<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // // This script will run when the page is loaded
        // window.onload = function () {
        //     let str = document.getElementById("hello").innerHTML;
        //     console.log(str);
        // };

    </script>
</head>

<body>
    <div id="hello">hello world!!!</div>
    <img id="img" src="images/1753146431514.jpg" />
</body>

</html>
<script>
    //2025年7月21日 10点00分00秒
    setInterval(function () {
        let now = new Date();
        let year = now.getFullYear();
        let month = zero(now.getMonth() + 1); // 月份从0开始
        let day = zero(now.getDate());
        let hours = zero(now.getHours());
        let minutes = zero(now.getMinutes());
        let seconds = zero(now.getSeconds());
        document.getElementById("hello").innerHTML = '' + year + '年' + month + '月' + day + '日 ' + hours + '时' + minutes + '分' + seconds + '秒';
    }, 1000);
    let zero = function (num) {
        return num < 10 ? '0' + num : num;
    };

    //图片轮播
    let images = [
        "images/1753146431514.jpg",
        "images/1753146457972.jpg",
        "images/1753146487402.jpg",
        "images/1753146516683.jpg",
    ];
    let index = 0;
    setInterval(function () {
        let img = document.getElementById("img")
        img.src = images[++index];
        if (index == images.length-1) {
            index = 0; // 重置索引
        }
    }, 3000);
</script>